<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" >
<head>
    <title>Getting Started: Serving Web Content</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link th:href="@{/css/1.css}" rel="stylesheet"/>
</head>
<style>
    .table1 tr td{
        width: 60px;
    }
</style>
<body>
<p th:text="'Hello, ' + ${title}" />
    <table class="table1">
        <tr th:each="u : ${pageInfo.list}">
            <td th:text="'姓名'"/>
            <td th:text="${u.name}"/>
            <td th:text="'年龄'"/>
            <td th:text="${u.age}"/>
            <td><a th:href="@{deleteUser(id=${u.id},pn=${pageInfo.pageNum})}">删除</a></td>
            <td>
                <form th:action="@{updateUser}" method="post">
                    <td><input type="text" th:name="name" th:value="${u.name}"/></td>
                    <td><input type="text" th:name="age" th:value="${u.age}"/>
                        <input type="hidden" name="id" th:value="${u.id}"/>
                        <input type="hidden" name="pn" th:value="${pageInfo.pageNum}"/></td>
                    <td><input type="submit" th:value="提交"/></td>
                </form>
            </td>
        </tr>
    </table>
    <table>
        <tr>
            <td><p th:text="'当前第'+ ${pageInfo.pageNum}+ '页.总共' + ${pageInfo.pages} + '页.一共' + ${pageInfo.total} + '条记录' "/></td>
            <td><a th:href="@{/hello(pn=1)}"> 首页 </a></td>
            <td th:if="${pageInfo.hasPreviousPage}"><a th:href="@{/hello(pn=${pageInfo.pageNum-1})}" th:text="《"/></td>
            <td th:each="num : ${pageInfo.navigatepageNums}">
                <td th:if="${num} eq ${pageInfo.pageNum}"><a href="#" style="color: red" th:text="${num}"/></td>
                <td th:if="${num} ne ${pageInfo.pageNum}"><a th:href="@{/hello(pn=${num})}" th:text="${num}"/></td>
            </td>
            <td th:if="${pageInfo.hasNextPage}"><a th:href="@{/hello(pn=${pageInfo.pageNum+1})}" th:text="》"/></td>
        </tr>
    </table>
<hr/>
<form th:action="@{addUser}" method="post">
    <input type="text" name="name"/>
    <input type="text" name="age"/>
    <input type="submit" value="提交"/>
</form>
<hr/>

</body>
</html>